using System;

namespace FreshMeat.ErrorHandlingBlock.Wcf
{
   /// <summary>
   /// Detects and remaps transient errors encountered by clients using WCF (Windows Communication Foundation).
   /// </summary>
   public class WcfTransientErrorDetector : ErrorDetector
   {
      /// <summary>
      /// Checks the error and either returns it unchanged or returns a substitute error.
      /// </summary>
      protected override Exception Check(Exception error)
      {
         // The default wording for this is insane.  Let's make it end-user friendly.
         if (error is TimeoutException)
            return new TimeoutException("The operation exceeded the alotted time.");

         return null;
      }
   }
}